//
//  ImportWalletInputCell.m
//  ShandsMod
//
//  Created by zh s on 2023/3/21.
//  Copyright © 2023 zh_s. All rights reserved.
//

#import "ImportWalletInputCell.h"

@interface ImportWalletInputCell ()<UITextViewDelegate>
/**! placeholderLab*/
@property (nonatomic, strong) UILabel *placeholderLab;

@end

@implementation ImportWalletInputCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.accessoryType = UITableViewCellAccessoryNone;
        self.backgroundColor = [UIColor clearColor];
        [self createView];
    }
    return self;
}

- (void)createView {
    UIView *backV = [[UIView alloc] init];
    [self.contentView addSubview:backV];
    backV.backgroundColor = UIColor.whiteColor;
    backV.frame = CGRectMake(20, 0, SCREEN_WIDTH - 40, 155);
    [backV settingShadowOpacity:0.2 withShadowColor:RGB(153, 153, 153) wihtShadowRadius:5 withshadowOffset:CGSizeMake(0, 3)];
    GWRadius(backV, 10);

    UITextView *inputTV = [[UITextView alloc] init];
    [backV addSubview:inputTV];
    inputTV.delegate = self;
    inputTV.showsVerticalScrollIndicator = NO;
    inputTV.backgroundColor = UIColor.whiteColor;
    inputTV.font = FONT_NAME(FONT_Regular, 14);
    [inputTV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(14);
        make.top.mas_equalTo(14);
        make.right.mas_equalTo(backV.mas_right).mas_offset(-14);
        make.height.mas_equalTo(125);
    }];
    
    UILabel *placeholderLab = [[UILabel alloc] init];
    [inputTV addSubview:placeholderLab];
    placeholderLab.textColor = RGB(175, 182, 203);
    placeholderLab.font = FONT_NAME(FONT_Regular, 14);
    placeholderLab.text = @"请输入明文私钥或扫二维码";
    [placeholderLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(1);
        make.top.mas_equalTo(2);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 24));
    }];
    self.placeholderLab = placeholderLab;

}

//给mode的nodeValue赋值 提交时候要用到
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
    NSString * toBeString = [textView.text stringByReplacingCharactersInRange:range withString:text];
    if (toBeString.length > 0) {
        self.placeholderLab.hidden = YES;
    }else {
        self.placeholderLab.hidden = NO;
    }
    
//    if (self.delegate && [self.delegate respondsToSelector:@selector(remarkInputContentWithContent:)]) {
//        [self.delegate remarkInputContentWithContent:toBeString];
//    }
    return YES;
}

@end
